﻿@using CubicFWNet.Common
@using CubicFWNet.Data.Models
@using CubicFWNet.Data.ViewModal
@using Newtonsoft.Json
@model Order
@{
    var invoiceList = ViewBag.InvoiceList as IEnumerable<Invoice>;
    var customer = ViewBag.Customer as Customer;
    var xiaoshou = ViewBag.Xiaoshou as User;
    var proList = ViewBag.ProList as List<ProductTechnologyView>;
    var invoiceListDistinct = ViewBag.InvoiceListDistinct as List<DeliveryProduct>;
    var operationName = ViewBag.OperationName;
    var operationTime = ViewBag.OperationTime;
    //List<decimal> deciList = new List<decimal>();
}
<section class="content-header">
    <h1>
        发货单详情
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("InvoiceQuery", "CustomerService")">发货单查询</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                @if (Model != null && invoiceList != null && customer != null && xiaoshou != null)
                {
                    <form class="form-horizontal" id="frmedit" action="@Url.Action("UpdateInvoiceCompose", "CustomerService")" method="post">
                        <input type="hidden" id="OrderId" name="OrderId" value="@Model.Id" />
                        <input type="hidden" id="fhd" name="fhd" value="1" />
                        <div class="box-body">
                            <div class="col-md-12 ">
                                <div class="form-group col-md-12" style="height: 1px;"></div>
                                <table class="footable table table-stripped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th data-sort-ignore="true">
                                                品名
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                尺寸宽-mm
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                尺寸长-mm
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                基本单位
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                订货数量
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                价格
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if (proList != null)
                                        {
                                            var totalWorth = Convert.ToDecimal(0);
                                            foreach (var item in proList)
                                            {
                                                <tr class="tr">
                                                    <td>
                                                        @if (string.IsNullOrEmpty(item.ProductNameOth))
                                                        {
                                                            @item.ProductName
                                                        }
                                                        else
                                                        {
                                                            @item.ProductNameOth
                                                        }
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.SizeWidth)
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.SizeLenth)
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.Unit)
                                                    </td>
                                                    <td>
                                                        <span style="color: red;font-weight: bold">@Html.DisplayFor(modelItem => item.Amount)</span>
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.Price)
                                                    </td>
                                                </tr>
                                            }
                                        }
                                    </tbody>
                                </table>
                            </div>

                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">内部订单号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" value="@Model.Number" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">客户订单号</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="Number" name="Number" value="@Model.CusNumber" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">客户名称</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="customerName" name="customerName" value="@customer.Name" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div id="json-contentData">
                                @foreach (var item in invoiceList)
                                {
                                    var products = JsonConvert.DeserializeObject<List<dynamic>>(item.Data);
                                    <div class="col-md-12 json-ItemcontentData ItemcontentData">
                                        <input type="hidden" id="itemData" value="@item.Data">
                                        <div class="form-group col-md-6">
                                            <label for="operationName" class="col-sm-3 control-label">发货单号</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" value="@item.Number" readonly="readonly">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="operationName" class="col-sm-3 control-label">运输审核备注</label>
                                            <div class="col-sm-9">
                                                <textarea class="form-control" rows="3" readonly="readonly">@item.ExamineMemo</textarea>
                                            </div>
                                        </div>
                                        @*<div class="form-group col-md-6">
                                                <label for="operationName" class="col-sm-3 control-label">选择</label>
                                                <div class="col-sm-9" style="padding-top: 7px; margin-bottom: 0;">
                                                    <input type="checkbox" class="minimal pull-right minimalBox" checked="checked" data-num="@item.Id" data-orderid="@item.OrderId">
                                                </div>
                                            </div>*@
                                        <table class="footable table table-stripped table-bordered table-hover" id="footable2">
                                            <thead>
                                                <tr>
                                                    <th data-sort-ignore="true">
                                                        品名
                                                    </th>
                                                    <th data-hide="phone,table" data-sort-ignore="true">
                                                        尺寸宽-mm
                                                    </th>
                                                    <th data-hide="phone,table" data-sort-ignore="true">
                                                        尺寸长-mm
                                                    </th>
                                                    <th data-hide="phone,table" data-sort-ignore="true">
                                                        基本单位
                                                    </th>
                                                    <th data-hide="phone,table" data-sort-ignore="true" class="col-md-2">
                                                        数量
                                                    </th>
                                                    <th data-hide="phone,table" data-sort-ignore="true" class="col-md-2">
                                                        价格
                                                    </th>
                                                    <th data-hide="phone" data-sort-ignore="true">
                                                        增值税
                                                    </th>
                                                    <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                        开票总额
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                @if (products.Count > 0)
                                                {
                                                    foreach (var itempro in products)
                                                    {
                                                        <tr class="tr">
                                                            <td>
                                                                @itempro.ProductName
                                                                <input type="hidden" class="form-control" data-des="产品Id" id="ProductId" name="ProductId" value="@itempro.ProductId">
                                                                <input type="hidden" class="form-control" data-des="品名" id="ProductName" name="ProductName" value="@itempro.ProductName">
                                                            </td>
                                                            <td>
                                                                @itempro.ProductSizeWidth
                                                                <input type="hidden" class="form-control" data-des="尺寸宽-mm" id="ProductSizeWidth" name="ProductSizeWidth" value="@itempro.ProductSizeWidth">
                                                            </td>
                                                            <td>
                                                                @itempro.ProductSizeLenth
                                                                <input type="hidden" class="form-control" data-des="尺寸长-mm" id="ProductSizeLenth" name="ProductSizeLenth" value="@itempro.ProductSizeLenth">
                                                            </td>
                                                            <td>
                                                                @itempro.ProductUnit
                                                                <input type="hidden" class="form-control" data-des="基本单位" id="ProductUnit" name="ProductUnit" value="@itempro.ProductUnit">
                                                            </td>
                                                            <td>
                                                                <input type="hidden" class="form-control itemAmount" data-des="数量" data-itemprice="@itempro.ProductPrice" id="ProductAmount" name="ProductAmount" value="@itempro.ProductAmount" readonly="readonly">
                                                                @itempro.ProductAmount
                                                            </td>
                                                            <td>
                                                                <input type="hidden" class="form-control itemPrice" data-des="价格" id="ProductPrice" name="ProductPrice" value="@itempro.ProductPrice" readonly="readonly">
                                                                @itempro.ProductPrice
                                                            </td>
                                                            <td>
                                                                <input type="hidden" class="form-control" data-des="增值税" id="ProductTax" name="ProductTax" value="@itempro.ProductTax">
                                                                @itempro.ProductTax
                                                            </td>
                                                            <td>
                                                                @itempro.TotalMoney
                                                                <input type="hidden" class="form-control itemMoney" data-des="开票总额" id="TotalMoney" name="TotalMoney" value="@itempro.TotalMoney" readonly="readonly">
                                                            </td>
                                                        </tr>
                                                    }
                                                }
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="form-group col-md-12" style="height: 1px;"></div>
                                }
                            </div>

                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div id="json-surplusContent" class="col-md-12 ">
                                @*col-md-offset-1*@
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">待开发票合计数量</label>
                                    <div class="col-sm-9">
                                        &nbsp;
                                    </div>
                                </div>
                                <div class="form-group col-md-12" style="height: 1px;"></div>
                                <table class="footable table table-stripped table-bordered table-hover" id="footable1">
                                    <thead>
                                        <tr>
                                            <th data-sort-ignore="true">
                                                品名
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                尺寸宽-mm
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                尺寸长-mm
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                基本单位
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                数量
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                价格
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                增值税
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                开票总额
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if (invoiceListDistinct != null)
                                        {
                                            foreach (var item in invoiceListDistinct)
                                            {
                                                <tr class="tr">
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductName)
                                                        <input type="hidden" class="form-control" data-des="产品Id" id="ProductId" name="ProductId" value="@item.ProductId">
                                                        <input type="hidden" class="form-control" data-des="品名" id="ProductName" name="ProductName" value="@item.ProductName">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductSizeWidth)
                                                        <input type="hidden" class="form-control" data-des="尺寸宽-mm" id="ProductSizeWidth" name="ProductSizeWidth" value="@item.ProductSizeWidth">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductSizeLenth)
                                                        <input type="hidden" class="form-control" data-des="尺寸长-mm" id="ProductSizeLenth" name="ProductSizeLenth" value="@item.ProductSizeLenth">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductUnit)
                                                        <input type="hidden" class="form-control" data-des="基本单位" id="ProductUnit" name="ProductUnit" value="@item.ProductUnit">
                                                    </td>
                                                    <td>
                                                        <input type="hidden" class="form-control itemAmount" data-des="数量" name="ProductAmount" value="@item.ProductAmount" readonly="readonly">
                                                        @Html.DisplayFor(modelItem => item.ProductAmount)
                                                    </td>
                                                    <td>
                                                        <input type="hidden" class="form-control itemPrice" data-des="价格" id="ProductPrice" name="ProductPrice" value="@item.ProductPrice" readonly="readonly">
                                                        @Html.DisplayFor(modelItem => item.ProductPrice)
                                                    </td>
                                                    <td>
                                                        @item.ProductTax
                                                        <input type="hidden" class="form-control" data-des="增值税" id="ProductTax" name="ProductTax" value="@item.ProductTax">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.TotalMoney)
                                                        <input type="hidden" class="form-control itemMoney" data-des="开票总额" id="TotalMoney" name="TotalMoney" value="@item.TotalMoney.ToString("f2")" readonly="readonly">
                                                    </td>
                                                </tr>
                                            }
                                        }
                                    </tbody>
                                </table>
                            </div>

                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div id="json-content" class="col-md-12 ">
                                @*col-md-offset-1*@
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">本次对账数量</label>
                                    <div class="col-sm-4">
                                        <span id="expExcel" class="btn btn-primary submitbtn">导出Excel</span>
                                    </div>
                                    <div class="col-sm-4">
                                        <select class="form-control" name="Type" id="Type">
                                            <option value="0">开票</option>
                                            <option value="1">不开票</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-md-12" style="height: 1px;"></div>
                                <table class="footable table table-stripped table-bordered table-hover" id="footable">
                                    <thead>
                                        <tr>
                                            <th data-hide="phone" style="display: none">
                                                <input type="hidden" value="客户名称" class="expExa" />
                                            </th>
                                            <th data-hide="phone" style="display: none">
                                                <input type="hidden" value="订单号" class="expExa" />
                                            </th>
                                            <th data-hide="phone" style="display: none">
                                                <input type="hidden" value="发货日期" class="expExa"/>
                                            </th>
                                            <th data-hide="phone" style="display: none">
                                                <input type="hidden" value="销售员" class="expExa" />
                                            </th>
                                            <th data-sort-ignore="true">
                                                品名
                                                <input type="hidden" value="品名" class="expExa" />
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                尺寸宽-mm
                                                <input type="hidden" value="尺寸宽-mm" class="expExa" />
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                尺寸长-mm
                                                <input type="hidden" value="尺寸长-mm" class="expExa" />
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                基本单位
                                                <input type="hidden" value="基本单位" class="expExa" />
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                数量
                                                <input type="hidden" value="数量" class="expExa" />
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                价格
                                                <input type="hidden" value="价格" class="expExa" />
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                增值税
                                                <input type="hidden" value="增值税" class="expExa" />
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                开票总额
                                                <input type="hidden" value="开票总额" class="expExa" />
                                            </th>

                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if (invoiceListDistinct != null)
                                        {
                                            foreach (var item in invoiceListDistinct)
                                            {
                                                <tr class="tr">
                                                    <td style="display: none">
                                                        <input type="hidden" class="form-control expExa" value="@customer.Name">
                                                    </td>
                                                    <td style="display: none">
                                                        <input type="hidden" class="form-control expExa" value="@Model.CusNumber">
                                                    </td>
                                                    <td style="display: none">
                                                        <input type="hidden" class="form-control expExa" value="@Model.SendTime">
                                                    </td>
                                                    <td style="display: none">
                                                        <input type="hidden" class="form-control expExa" value="@xiaoshou.ShortName">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductName)
                                                        <input type="hidden" class="form-control" data-des="产品Id" id="ProductId" name="ProductId" value="@item.ProductId">
                                                        <input type="hidden" class="form-control expExa" data-des="品名" id="ProductName" name="ProductName" value="@item.ProductName">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductSizeWidth)
                                                        <input type="hidden" class="form-control expExa" data-des="尺寸宽-mm" id="ProductSizeWidth" name="ProductSizeWidth" value="@item.ProductSizeWidth">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductSizeLenth)
                                                        <input type="hidden" class="form-control expExa" data-des="尺寸长-mm" id="ProductSizeLenth" name="ProductSizeLenth" value="@item.ProductSizeLenth">
                                                    </td>
                                                    <td>
                                                        @Html.DisplayFor(modelItem => item.ProductUnit)
                                                        <input type="hidden" class="form-control expExa" data-des="基本单位" id="ProductUnit" name="ProductUnit" value="@item.ProductUnit">
                                                    </td>
                                                    <td>
                                                        <input type="text" class="form-control okeydown itemAmount expExa" data-des="数量" data-itemprice="@item.ProductPrice" data-total="@item.ProductAmount" id="ProductAmount" name="ProductAmount" value="@item.ProductAmount" required>
                                                        @*@Html.DisplayFor(modelItem => item.ProductAmount)*@
                                                    </td>
                                                    <td>
                                                        <input type="hidden" class="form-control itemPrice expExa" data-des="价格" id="ProductPrice" name="ProductPrice" value="@item.ProductPrice" readonly="readonly">
                                                        @Html.DisplayFor(modelItem => item.ProductPrice)
                                                    </td>
                                                    <td>
                                                        @item.ProductTax
                                                        <input type="hidden" class="form-control productTaxClass expExa" data-des="增值税" id="ProductTax" name="ProductTax" value="@item.ProductTax">
                                                    </td>
                                                    <td>
                                                        @*@Html.DisplayFor(modelItem => item.TotalMoney)*@
                                                        <input type="text" class="form-control itemMoney expExa" data-des="开票总额" id="TotalMoney" name="TotalMoney" value="@item.TotalMoney.ToString("f2")" readonly="readonly">
                                                    </td>
                                                </tr>
                                            }
                                        }
                                    </tbody>
                                </table>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">对账备注</label>
                                <div class="col-sm-9">
                                    <textarea class="form-control" rows="3" placeholder="请输入 ..." name="Memo" id="Memo"></textarea>
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div class="form-group col-md-6">
                                <label for="operationName" class="col-sm-3 control-label">操作人</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationName" name="operationName" value="@operationName" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="operationTime" class="col-sm-3 control-label">日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationTime" name="operationTime" value="@operationTime" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="box-footer" style="width: 80%; margin-left: 20px;">
                            <a role="button" href="javascript:void(0)" class="btn btn-primary submitbtn" onclick="formsubmit(1)">确认对账</a>
                            <a class="btn btn-primary submitbtn" href="@Url.Action("InvoiceQuery", "CustomerService")">返回</a>
                        </div>
                    </form>
                }
            </div>
        </div>
    </div>
</section>

<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

@section Scripts{
    <script src="~/Scripts/jquery.table2excel.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#frmedit").validate({
                submitHandler: function (form) {
                    var postData = $(form).formSerialize();
                    postData.ProductData = getParam();
                    $.submitForm({
                        url: $(form).attr("action"),
                        param: postData,
                        success: function () {
                            //$.reload();
                            $.modalAlert("操作成功", "success");
                            window.location.href = '@Url.Action("InvoiceQuery", "CustomerService")';
                        }
                    });
                    @*$.ajax({
                        url: $(form).attr("action"),
                        data: postData,
                        type: "post",
                        success: function (data) {
                            var mes = JSON.parse(data);
                            if (mes.Status == "1") {
                                $.modalAlert("操作成功", "success");
                            } else {
                                $.modalAlert("操作失败", "success");
                            }
                            //window.location.href = '@Url.Action("InvoiceQuery", "CustomerService")';
                        }
                    });*@
                }
            });
            //$('#footable').footable();
            //foreachData();

        });

        var type = 1;

        function formsubmit(t) {
            /*var len = $("#fhd").val();
            if (len == "0") {
                $.modalAlert("请选择发货单", "warning");
                return false;
            }*/
            var len = JSON.parse(getParam());
            if (len.length == 0) {
                $.modalAlert("不可提交0数据", "warning");
                return false;
            }
            if (!isNaN(len) && (len / 1) > 117000) {
                $.modalAlert("单张发票总额不可大于11.7万", "warning");
                return false;
            }
            type = t;
            $("#frmedit").submit();
        }

        $(".itemAmount").keyup(function () {
            var amount = $(this).val() / 1;
            var price = $(this).attr('data-itemprice') / 1;
            var totalAmount = $(this).attr('data-total') / 1;
            if (isNaN(amount) || amount <= 0) {
                amount = 0;
                $(this).val(0);
            }
            if (amount > totalAmount) {
                amount = totalAmount;
                $(this).val(amount);
            }
            if (amount == 0) {
                $(this).parents(".tr").addClass("noExl");
            } else {
                $(this).parents(".tr").removeClass("noExl");
            }
            var tax = $(this).parents(".tr").find(".productTaxClass").val();
            if (isNaN(tax)) {
                tax = 1.17;
            }
            tax = tax / 1;
            var b = (amount * price * tax).toFixed(2);
            $(this).parents(".tr").find(".itemMoney").val(b);
        });

        function getParam() {
            var postdata = [];
            var totalMoney = 0;
            //主键
            $("#json-content").find('.tr').each(function (r, i) { //input,select,textarea
                var postdataItem = {};
                var flag = true;
                $(i).find('input').each(function (m) {
                    var $this = $(this);
                    var id = $this.attr('id');
                    var value = $this.val();
                    postdataItem[id] = value;
                    if (id == "ProductAmount") {//数量为0则不加入json中
                        if (!isNaN(value) && (value / 1) <= 0) {
                            flag = false;
                        }
                        if (isNaN(value)) {
                            flag = false;
                        }
                    }
                    if (id == "TotalMoney" && !isNaN(value)) {//总计金额
                        totalMoney += value / 1;
                    }
                });
                if (flag) {
                    postdata.push(postdataItem);
                }
            });
            if (!isNaN(totalMoney) && (totalMoney / 1) > 117000) {
                return JSON.stringify(totalMoney);
            }
            return JSON.stringify(postdata);
        }


        //$('input[type="checkbox"].minimal,input[type="radio"].minimal').iCheck({
        //    checkboxClass: 'icheckbox_minimal-blue',
        //    radioClass: 'iradio_minimal-blue'
        //});

        function foreachData() {
            var postdata = [];
            var postProIds = [];
            $("#json-contentData").find('.ItemcontentData').each(function (t, e) {
                var $totaThis = $(this);
                $totaThis.find('.tr').each(function (r, i) { //input,select,textarea
                    var postdataItem = {};
                    $(i).find('input').each(function (m) {
                        var $this = $(this);
                        var id = $this.attr('id');
                        postdataItem[id] = $this.val();
                    });
                    postdata.push(postdataItem);
                });
            });
            postdata.forEach(function (data, index) {
                if (postProIds.indexOf(data.ProductId) > -1) {//包含

                } else {//不包涵
                    postProIds.push(data.ProductId); //添加对应的Id'
                }
            });
            postProIds.forEach(function (data, index) {
                var amount = 0;
                var money = 0;
                var price = 0;
                postdata.forEach(function (dataobj, ind) {
                    if (data.indexOf(dataobj.ProductId) > -1) {//包含
                        amount += (dataobj.ProductAmount / 1);
                        price = dataobj.ProductPrice / 1;
                    }
                });
                $("#ProductAmount-" + data).val(amount);
                money = amount * price;
                $("#TotalMoney-" + data).val(money.toFixed(2));
            });

            $("#fhd").val(postdata.length);
            console.log(postdata);
            console.log("----");
            console.log(postProIds);
            console.log(">>>>>>>>>>>>>>>>>>>");
            //return JSON.stringify(postdata);
        }



        $(".okeydown").on("keydown", function () {
            var k = event.keyCode;
            if ((k <= 57 && k >= 48) || (k <= 105 && k >= 96) || (k == 8) || (k == 110) || (k == 190)) {
                return true;
            } else {
                return false;
            }
        });

        $("#expExcel").click(function () {
            updadeExpExcel();
            $("#footable").table2excel({
                exclude: ".noExl",
                name: "对账表",
                filename: "对账表",
                exclude_img: false,
                exclude_links: false,
                exclude_inputs: false
            });
        });

        function updadeExpExcel() {
            //主键
            $("#json-content").find('.tr').each(function (r, i) { //input,select,textarea
                $(i).find('input').each(function (m) {
                    var $this = $(this);
                    var id = $this.attr('id');
                    var value = $this.val();
                    if (id == "ProductAmount") {
                        if (!isNaN(value) && (value == 0)) {
                            $(this).parents(".tr").addClass("noExl");
                        }
                        if (isNaN(value)) {
                            $(this).parents(".tr").addClass("noExl");
                        }
                    }
                });
            });
        }
        //多选选中
        //$('input[type="checkbox"].minimalBox').on('ifClicked', function (event) {
        //    //现在判断时若是选中的，点击完了就变成了未选中了
        //    if ($(this).is(":checked")) {
        //        $(this).parents(".json-ItemcontentData").removeClass("ItemcontentData");
        //    } else { //这里判断是没选中，点击完了就变成选中了
        //        $(this).parents(".json-ItemcontentData").addClass("ItemcontentData");
        //    }
        //    foreachData();
        //});
    </script>
}